package com.chuantou.yuba.ui.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

import com.android.volley.toolbox.NetworkImageView;
import com.chuantou.yuba.R;

public class AlbumItem extends NetworkImageView {
	private boolean mIsChecked = false;

	public AlbumItem(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public AlbumItem(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public AlbumItem(Context context) {
		super(context);
	}

	public void setChecked(boolean checked) {
		this.mIsChecked = checked;
		invalidate();
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		Drawable drawable = null;
		if (mIsChecked) {
			drawable = getResources().getDrawable(R.drawable.album_checked);
		} else {
			drawable = getResources().getDrawable(R.drawable.album_unchecked);
		}
		drawable.setBounds(getWidth() - drawable.getIntrinsicWidth(), 0, getWidth(), drawable.getIntrinsicHeight());
		drawable.draw(canvas);
	}

}
